package com.enjoyor.soa.traffic.server.tsms.dubbo.impl;

import org.springframework.stereotype.Component;

import com.alibaba.dubbo.config.annotation.Reference;
import com.enjoyor.soa.traffic.api.serverpush.server.dubbo.DubboServerPushService;
import com.enjoyor.soa.traffic.server.tsms.TsmsServerApplication;
import com.enjoyor.soa.traffic.util.pojo.ResultPojo;

import com.alibaba.fastjson.JSONObject;


@Component
public class DubboServerPushServiceImpl {
	
	@Reference(timeout = 10000)
	private DubboServerPushService service;


	/**
	 * 获取客户端连接的基地址
	 *
	 * @deprecated 弃用，请使用 {@link #getJsPath()}.
	 */
	public ResultPojo getBasePath(){
		return service.getBasePath();
	}

	/**
	 * 获取客户端js
	 */
	public ResultPojo getJsPath(){
		return service.getJsPath();
	}

	/**
	 * 向客户端推送消息
	 *
	 * @param namespace
	 *            通道
	 * @param message
	 *            消息。<s>注意：message中不要含有自定义的java对象，而应转换为String,int,Ineger,Date,Map等
	 *            java自带对象</s>(已修正)
	 * @return ResultPojo.resultList 推送的客户端数(可能不准确，因IE等不支持WebSocket的客户端使用JSONP
	 *         Polling，关闭后需超时才下线)
	 */
	public ResultPojo pushMessage(String namespace, JSONObject message){
		return service.pushMessage(namespace, message);
	}

	public ResultPojo pushMessage(String namespace, String event, JSONObject message){
		return service.pushMessage(namespace, event, message);
	}
	
}
